﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>退回</title>
    <!--
    1, 退回界面。
    2，需要 FK_Flow, FK_Node,WorkID, FID.
    3, 调用方法 ReturnWork.htm?FK_Flow=001&FK_Node=103&WorkID=232&FID=23
    -->
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>
    <script src="../Scripts/commonYangYH.js"></script>
    <!-- 导入配置文件. -->
    <!-- 该文件可以被集成厂商自己定义风格,可以自己修改,以达到流程设计器与自己的系统风格统一. -->
    <link href="../../DataUser/Style/ccbpm.css" rel="Stylesheet" />
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Scripts/config.js" type="text/javascript" ></script>
    <script type="text/javascript" src="../Comm/Gener.js" ></script>
    <style type="text/css">
        body {
            background: transparent;
        }

            body div {
                text-align: left;
                margin: 20px auto;
            }

        #Message {
            width: 100%;
        }
    </style>
    <script type="text/javascript">
        var pageData = {};
        $(function () {

            //初始化页面退回信息.
            pageData = {
                FK_Node: GetQueryString('FK_Node'),
                WorkID: GetQueryString('WorkID'),
                FID: GetQueryString('FID'),
                Message: GetQueryString('Info'),
                FK_Flow: GetQueryString("FK_Flow")
            };

            if (pageData.Message != undefined && pageData.Message != '') {
                $('#TB_Doc').val(pageData.Message);
            }

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddUrlData();

            var data = handler.DoMethodReturnString("Return_Init");

            if (data.indexOf('err@') == 0) {

                console.error("退回窗口错误信息" + data);

                data = data.replace('err@', '');
                data = "<font color=red>"+data+"</font>";
                $("#Msg").html(data);
                //  alert(data);
                return;
            }

            var returnNodeArr = JSON.parse(data);
            var nodeListHtml = '';

            $.each(returnNodeArr, function (i, returnNode) {

                if (returnNode.AtPara && returnNode.AtPara.indexOf('IsHuiQian=1') >= 0) {
                    return true;
                }

                nodeListHtml += '<option data-IsBackTracking=' + returnNode.IsBackTracking + ' value="' + returnNode.No + '@' + returnNode.Rec + '">' + returnNode.RecName + '=&gt;' + returnNode.Name + '</option>';
            });


            $('#DDL_Nodes').html(nodeListHtml);

            // $('#DDL_Nodes').html(DDL_NodesHtml);

            $('#DDL_Nodes').bind('change', SetIsBackTrackingDispaly);
            SetIsBackTrackingDispaly();

            $("section").show();
            $(".wait").hide();

            Common.MaxLengthError();
        });

        function SetIsBackTrackingDispaly() {

            // alert($('#DDL_Nodes option:checked').data().isbacktracking);

            if ($('#DDL_Nodes option:checked').data().isbacktracking == 0) {
                $('#btnIsBackTracking').css('display', 'none');
            } else {
                $('#btnIsBackTracking').css('display', 'inline-block');
            }

            //ie9
            if ($('#DDL_Nodes option:checked').attr("data-isbacktracking") == 0) {
                $('#btnIsBackTracking').css('display', 'none');
            } else {
                $('#btnIsBackTracking').css('display', 'inline-block');
            }
        }


        //确定 退回 执行退回操作
        function ReturnWork(isBack) {
            //WorkID, this.FID, this.FK_Node

            var selectedNodeID = $('#DDL_Nodes').val();


            var val = escape($('#TB_Doc').val());
            if (val == null || val == "" || val == undefined) {
                alert("请输入退回原因.");
                return;
            }

            if (selectedNodeID == null || selectedNodeID == undefined || selectedNodeID == "") {
                alert('请选择要退回的节点');
                return;
            }

            $('.foot input').attr('disabled', 'disabled');
            $('.foot input').css('background', 'gray');
            var doc = "";
            if (plant == 'CCFlow') {
                doc = escape($('#TB_Doc').val());
            } else {
                doc = $('#TB_Doc').val();
            }
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddPara("FK_Flow", pageData.FK_Flow);
            handler.AddPara("WorkID", pageData.WorkID);
            handler.AddPara("FID", pageData.FID);
            handler.AddPara("FK_Node", pageData.FK_Node);
            handler.AddPara("ReturnToNode", selectedNodeID);
            handler.AddPara("ReturnInfo", doc);
            handler.AddPara("IsBack", isBack);
            var data = handler.DoMethodReturnString("DoReturnWork");
            if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                window.parent.returnWorkWindowClose(data);
            } else if (window.opener != undefined && window.opener.returnWorkWindowClose != undefined) {
                window.opener.returnWorkWindowClose(data);
            } else {
                $('body').append($('<div>' + data + '</div>'));
                $('#btnOk').attr('disabled', true);
            }

            $(".foot").hide();
        }

        //取消退回
        function Close() {
            if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                window.parent.returnWorkWindowClose("取消");
            }
            else {
                $('body').append($('<div>' + "已取消操作" + '</div>'));
                window.close();
            }
        }
      
    </script>
</head>
<body>
<div class="wait" style="text-align: center;" id="Msg" >页面数据正在加载中，请稍候......</div>
    <div>
        请选择要退回到的节点:<br />
        <select id="DDL_Nodes" name="DDL_Nodes" style="width: 77%;"></select>
    </div>
    <div>
        退回原因：
        <textarea id="TB_Doc" name="TB_Doc" style="vertical-align: top; width: 98%; height:150px;" maxlength="500"></textarea>
    </div>
    
    <!--<div> 上传附件：</div>
    <div style="height:100px;">上传附件预留：该功能正在建设中</div>
-->
    <div style="position: fixed; bottom: 0px; right: 0px;" class="foot">
        <input type="button" value="确定退回" onclick="ReturnWork(0);" />
        <input type="button" value="退回后并发送给我" onclick="ReturnWork(1);" id="btnIsBackTracking" />
        <input type="button" value="关闭" onclick="Close();" />
    </div>
</body>
</html>
